import org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import educar.models.User;
import educar.models.userNotFound;


public class AsAnUnauthenticatedUser {

	@Before
	public void setUp() throws Exception {
		User u = new User(35413290,"juan","firulais","docente");
		u.save();
	}

	@Test
	public void IWantToBeLoggedIfIProvideTheRightCredentials() {
		assertEquals(User.authenticate("juan","firulais"), true);
	}
	
	@Test
	public void IShouldNotBeLoggedInIfIProvideBadCredentials(){
		assertEquals(User.authenticate("jose","********"), false);
	}

	@After
	public void tearDown(){
		try {
			User.getUserByUsername("juan").destroy();
		} catch (userNotFound e) {
			e.printStackTrace();
		}
	}
	
	/**@Before
	public void setUp() throws Exception {
		User u = new User(35260999,"miriam","luna", "alumno");
		u.save();
	}

	@Test
	public void IWantToBeLoggedIfIProvideTheRightCredentials() {
		assertEquals(User.authenticate("miriam","luna"), true);
	}
	
	@Test
	public void IShouldNotBeLoggedInIfIProvideBadCredentials(){
		assertEquals(User.authenticate("juan","abcdefg"), false);
	}

	@After
	public void tearDown(){
		try {
			User.getUserByUsername("miriam").destroy();
		} catch (userNotFound e) {
			e.printStackTrace();
		}
	}*/
	
	public boolean assertEquals(boolean x, boolean y){
		return (x && y);
	}
}
